<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 异步任务
    // 计时器/延时器/ajax  
    // Promise对象的then() catch()

    // 1 3 6

    console.log(1);

    setTimeout(() => { // callback1
        console.log(2);
    })

    var p = new Promise((resolve, reject) => {
        console.log(3);
        resolve();
    })

    p.then((res) => { // callback2
        console.log(4);
    }).catch(res => {
        console.log("rejected", res);
    })

    setTimeout(() => { // callback3
        console.log(5);
    })


    console.log(6);

</script>

</html>